package com.bigstar.lolen_e;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.ads.AdRequest;
import com.google.ads.AdView;

public class SummonerSpells extends Activity{
	public static final String[] spells_name_en = new String[] {
		"Exhaust","Garrison","Ghost","Heal",
		"Revive","Smite","Surge","Teleport",
		"Cleanse","Clarity","Ignite","Promote",
		"Clairvoyance","Flash","Barrier"
	};
	public static final String[] spells_text = new String[] {
		"Summoner Level : 1\r\nCooldown : 210sec\r\nRange : 500\r\n[Classic, Dominion] Exhausts target champion, reducing their Movement Speed by 40%, attack damage dealt by 70%, and ability and item damage dealt by 35% for 2.5 seconds.",
		"Summoner Level : 1\r\nCooldown : 210sec\r\nRange : 475\r\n[Dominion] Allied Turret: Grants massive regeneration and Attack Speed for 8 seconds. Enemy Turret: Reduces damage dealt by 80% for 8 seconds.",
		"Summoner Level : 1\r\nCooldown : 210sec\r\nRange : Self\r\n[Classic, Dominion] Your champion ignores unit collision and has 27% increased Movement Speed for 10 seconds",
		"Summoner Level : 1\r\nCooldown : 270sec\r\nRange : 600\r\n[Classic, Dominion] Restores 125-590 Health (depending on champion level) to your champion and 50% of that to nearby allies.",
		"Summoner Level : 1\r\nCooldown : 540sec\r\nRange : Self\r\n[Classic, Dominion] Instantly revives your champion at your team's summoner platform and increases your champion's maximum health by 220-560 (200 + 20/lvl) for 2 minutes.",
		"Summoner Level : 1\r\nCooldown : 70sec\r\nRange : 800\r\n[Classic, Dominion] Smite deals 420 + (lvl x 25) True damage to a enemy minion, pet, neutral monster.",
		"Summoner Level : 1\r\nCooldown : 180sec\r\nRange : Self\r\n[Classic, Dominion] Empowers your champion, increasing ability power by 10-78 (depending on level) and attack speed by 35% for 12 seconds",
		"Summoner Level : 1\r\nCooldown : 300sec\r\nRange : Global\r\n[Classic, Dominion] After 4 seconds, it teleports your champion to target turret or friendly minion (making it invulnerable for the duration). Can be canceled.",
		"Summoner Level : 2\r\nCooldown : 150sec\r\nRange : Self\r\n[Classic, Dominion] Removes all stuns, slows, taunts, fears, snares, silences, blinds and immobilizers and lowers the duration of new ones applied by 65% for 3 seconds.",
		"Summoner Level : 6\r\nCooldown : 180sec\r\nRange : 600\r\n[Classic, Dominion] Restores 160 + 30x level mana to your champion and 50% of that to nearby allies.",
		"Summoner Level : 7\r\nCooldown : 180sec\r\nRange : 550\r\n[Classic, Dominion] Ignites an enemy unit, dealing 50 plus 20 x level true damage over time to a single target and reduces the health regeneration and the healing effects received by 50%.",
		"Summoner Level : 8\r\nCooldown : 180sec\r\nRange : 550\r\n[Classic, Dominion] Metamorphoses the nearest allied siege minion into an anti-turret cannon, healing it, granting bonus stats, and causing it to grant the caster gold for its kills.",
		"Summoner Level : 10\r\nCooldown : 70sec\r\nRange : Global\r\n[Classic, Dominion] Reveals an area of the map for 4 seconds.",
		"Summoner Level : 12\r\nCooldown : 265sec\r\nRange : 400\r\n[Classic, Dominion] Teleports your Champion to target nearby location.",
		"Summoner Level : 1\r\nCooldown : 125sec\r\nRange : Self\r\n[Proving Grounds] Shields your champion for 100 + (25 × level) for 4 seconds."
	};
    @Override
    protected void onResume() {
        ChampionData.load(this);
        ItemData.load(this);
        Rune.load(this);
    	super.onResume();
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        ChampionData.load(this);
        ItemData.load(this);
        Rune.load(this);
        
        setContentView(R.layout.summoner_spells);
        AdView adview = (AdView)findViewById(R.id.adView);
        AdRequest re = new AdRequest(); 
        adview.loadAd(re);
        GridView gridview = (GridView) findViewById(R.id.spells_grid);
        gridview.setAdapter(new ListAdapter());
        
        gridview.setOnItemClickListener(new OnItemClickListener(){
        	public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
        		ImageView iv = new ImageView(SummonerSpells.this);
        		iv.setImageResource(R.drawable.spellss_00+position);
        		new AlertDialog.Builder(SummonerSpells.this)
        		.setIcon(R.drawable.sspells_00+position)
        		.setTitle(spells_name_en[position])
        		.setView(iv)
        		.setMessage(spells_text[position])

        		.setPositiveButton("Close", new DialogInterface.OnClickListener() {
        			public void onClick(DialogInterface dialog, int whichButton) {
        			}
        		})
        		.create().show();
        	}
        });
    }
	
	class ListAdapter extends BaseAdapter {
		 
		 public ListAdapter () {
		 }
		 
		 public int getCount() {
			 return spells_name_en.length;
		 }
		 
		 public Object getItem(int position) {
		  return null;
		 }
		 
		 public long getItemId(int position){
		  return 0;
		 }
		 
		 // Create a New ImageView for each item referenced by the Adapter
		 public View getView(int position, View convertView, ViewGroup parent){
			 View v;
			 LayoutInflater li = getLayoutInflater(); 
			 v = li.inflate(R.layout.summoner_spells_row, null); 
			 TextView tv = (TextView)v.findViewById(R.id.s_spells_name); 
			 tv.setText(spells_name_en[position]);  
			 
			 ImageView iv = (ImageView)v.findViewById(R.id.s_spells_img); 
			 iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
			 iv.setImageResource(R.drawable.sspells_00+position); 

		  
			 return v;
		 }
	}
}
